package com.tgy.esp32Service.controller;

import com.tgy.esp32Service.dto.R;
import com.tgy.esp32Service.service.EspService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;

/***
 * @ClassName: EspController
 * @Description: esp32 消息发送服务接口
 * @Auther: tanggy3
 * @Date: 15:19 2022/9/14
 * @version : V1.0
 */
@Api(value = "接口", tags = {"接口"})
@RestController
@Slf4j
@RequestMapping("/esp32")
@AllArgsConstructor
public class EspController {

    private final EspService espService;

    @ApiOperation(value = "发送消息到esp32 目前仅支持英文")
    @GetMapping("/send")
    public R<String> sendMsg(@ApiParam("需要发送的消息 目前仅支持英文") @RequestParam String msg) {
        return R.ok(espService.sendMsg(msg));
    }

    @ApiOperation(value = "esp32 接收消息接口")
    @GetMapping("/get")
    public R<String> getMsg() {
        return R.ok(espService.getMsg());
    }
}
